<?php

namespace App\Http\Requests\Administrator;

use Illuminate\Validation\Rule;

class SiteRequest extends Request
{


    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        switch ($this->method()) {
            // CREATE
            case 'POST':
                {
                    return [
                        'site_name' => 'required|min:2|max:32|string',
                        'username' => 'required|min:2|max:32|alpha_num',
                        'is_external' => 'required|in:0,1',
                        'status' => 'required|in:0,1',
                        'name' => 'required|min:2|max:32|alpha_dash',
                        'password' => 'required|min:2|max:32|alpha_dash|confirmed',
                        'plats.rate.*' => 'nullable|numeric'
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    return [
                        'site_name' => 'required|min:2|max:32|string',
                        'is_external' => 'required|in:0,1',
                        'status' => 'required|in:0,1',
                    ];
                }
            case 'GET':
            case 'DELETE':
            default:
                {
                    return [];
                };
        }
    }
}
